package com.neusoft.elmboot.controller;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neusoft.elmboot.po.Wallet;
import com.neusoft.elmboot.service.WalletService;

@RestController
@RequestMapping("/WalletController")
@CrossOrigin
public class WalletController {

    @Autowired
    private WalletService walletService;

    @RequestMapping("/saveWallet")
    public int saveWallet(String userId) throws Exception{
        return walletService.saveWallet(userId);
    }

    @RequestMapping("/getWalletByUserid")
    public Wallet getWalletByUserid(String userId) throws Exception{
        return walletService.getWalletByUserid(userId);
    }

    @RequestMapping("/updateMoney")
    public int updateMoney(String userId, BigDecimal money) throws Exception{
        return walletService.updateMoney(userId, money);
    }

    @RequestMapping("/pay")
    public int pay(String userId,BigDecimal amount,Integer type) throws Exception{
        return walletService.pay(userId, amount, type);
    }

}
